#ifndef _BlendMaterial_H_
#define _BlendMaterial_H_

#pragma once
#include "Material.h"
class BlendMaterial : public Material {
public:
	enum BlendType {
		Add, Sub, Multiply, Divide,
		Darken, Lighten, Difference
	};
private:
	shared_ptr<Material> material1;
	shared_ptr<Material> material2;
	BlendType blendType;
	Float strength1;
	Float strength2;

	inline Color shade_M1(const Scene *scene, const Ray &ray, const IntersectResult &intersect, const TraceState & traceState) const {
		return material1->shade(scene, ray, intersect, traceState) *= strength1;
	}
	inline Color shade_M2(const Scene *scene, const Ray &ray, const IntersectResult &intersect, const TraceState & traceState) const {
		return material2->shade(scene, ray, intersect, traceState) *= strength2;
	}

public:
	BlendMaterial(shared_ptr<Material> material1, shared_ptr<Material> material2, BlendType blendType, Float strength1 = 1, Float strength2 = 1) :
		material1(material1), material2(material2), blendType(blendType), strength1(strength1), strength2(strength2) {}
	~BlendMaterial() {}

	Color shade(const Scene *scene, const Ray &ray, const IntersectResult &intersect, const TraceState & traceState) const;

	bool isLuminous() const;
	bool isTransparent() const;
	Color getTransparentColor(const Scene * scene, const Ray & ray, const IntersectResult &intersect) const;
};

#endif // _BlendMaterial_H_